Page({
  data: {
    avatar:
      "https://img1.baidu.com/it/u=3217838212,795208401&fm=253&fmt=auto&app=138&f=JPEG?w=514&h=500",
    selectPriceList: ["全部", "1-100", "100-500", "500-5000", "5000以上"],
    currentPriceIndex: 0,
    goodsList: [
      {
        cover: [
          "https://img1.rrzuji.cn/uploads/scheme/2204/01/m/ThfXUFuFvU7DC2HpXdWd.png",
        ],
        id: 99,
        imgOssServer: "https://img-t1.rrzuji.cn",
        init_sell_num: 450,
        is_free_shopping: 1,
        need_coin: 1650,
        need_pay: "6.00",
        position_sign: "61ad74b6cef0b9b566c6134f9c8d3fac",
        price: "26.00",
        sell_num: 0,
        sort: 9994,
        tags: "新品",
        target_id: "",
        title: "便携式勺筷餐具套装便携式勺筷餐具套装",
        total_num: 999,
        type: 1,
      },
      {
        cover: [
          "https://img1.rrzuji.cn/uploads/scheme/2209/17/m/zD7sf0bZQehOJxAxsfTL.png",
        ],
        id: 99,
        imgOssServer: "https://img-t1.rrzuji.cn",
        init_sell_num: 450,
        is_free_shopping: 1,
        need_coin: 1650,
        need_pay: "0.00",
        position_sign: "61ad74b6cef0b9b566c6134f9c8d3fac",
        price: "26.00",
        sell_num: 0,
        sort: 9994,
        tags: "新品",
        target_id: "",
        title: "便携式勺筷餐具套装",
        total_num: 999,
        type: 1,
      },
      {
        cover: [
          "https://img1.rrzuji.cn/uploads/scheme/2306/22/m/VZU06u5YVWfgcsOrMtTu.png",
        ],
        id: 99,
        imgOssServer: "https://img-t1.rrzuji.cn",
        init_sell_num: 450,
        is_free_shopping: 1,
        need_coin: 1650,
        need_pay: "0.00",
        position_sign: "61ad74b6cef0b9b566c6134f9c8d3fac",
        price: "26.00",
        sell_num: 0,
        sort: 9994,
        tags: "新品",
        target_id: "",
        title: "便携式勺筷餐具套装",
        total_num: 999,
        type: 1,
      },
      {
        cover: [
          "https://img1.rrzuji.cn/uploads/scheme/2303/13/m/NY6ehWW4bXQiO8VdbXmN.jpg",
        ],
        id: 99,
        imgOssServer: "https://img-t1.rrzuji.cn",
        init_sell_num: 450,
        is_free_shopping: 0,
        need_coin: 1650,
        need_pay: "0.00",
        position_sign: "61ad74b6cef0b9b566c6134f9c8d3fac",
        price: "26.00",
        sell_num: 0,
        sort: 9994,
        tags: "新品",
        target_id: "",
        title: "便携式勺筷餐具套装",
        total_num: 999,
        type: 1,
      },
    ],
    page_info: {
      total_count: 10,
      current_page: 1,
      page_size: 3,
      page_count: 4,
    },
    temporaryData: [],
  },
  // 处理选择价格范围
  selectPrice(e) {
    const { index } = e.currentTarget.dataset;
    this.setData({ currentPriceIndex: index });
  },
  onLoad() {},
  onReachBottom() {
    // 页面被拉到底部
    console.log("加载更多数据");
    // 先获取当前值
    const pageInfo = this.data.page_info;
    const newPageSize = pageInfo.current_page + 1;
    console.log("当前页数", pageInfo.current_page, "新页数", newPageSize, this.data.page_info);
    
    if (this.data.page_info.current_page < this.data.page_info.page_size) {
      if (!this.data.temporaryData.length) {
        this.setData({
          temporaryData: this.data.goodsList,
        })
      }
      this.setData({
        page_info: {
          ...this.data.page_info,
          current_page: newPageSize,
        },
        goodsList: [...this.data.goodsList, ...this.data.temporaryData],
      });
      my.showToast({
        content: "加载中",
        duration: 500,
      });
    }
  },
});
